package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author: yingjf
 * @date: 2022/8/17 09:37
 * @description: 竞争对手报价枚举
 */
@Getter
public enum CompetitorQuotedPriceEnum {
    //    较高、适中、较低、未知
    HIGH("1", "enum.competitorQuotedPrice.name.high", "high"),
    MODERATE("2", "enum.competitorQuotedPrice.name.moderate", "moderate"),
    LOW("3", "enum.competitorQuotedPrice.name.low", "low"),
    UNKNOWN("4", "enum.competitorQuotedPrice.name.unknown", "unknown"),
    ;
    private String code;
    private String name;
    private String attr;

    CompetitorQuotedPriceEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public static CompetitorQuotedPriceEnum getByCode(String code) {
        for (CompetitorQuotedPriceEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
